<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:mpeg7="urn:mpeg:mpeg7:schema:2001" xmlns:amp="mpeg7_amp" xmlns:voc="vocabularies" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="amp fn fo mpeg7 voc xs xsi">

<xsl:include href="top.xsl"></xsl:include>
<xsl:include href="down.xsl"></xsl:include>
<xsl:include href="utils.xsl"></xsl:include>

<!-- Parametros del xsl -->
<xsl:param name="time"/>
<xsl:param name="base_url"/>
<xsl:param name="keys_search"/>
<xsl:param name="action"/>
<xsl:param name="id"/>
<xsl:param name="start"/>
<xsl:param name="order"/>

<xsl:variable name="base_img">img/pc/</xsl:variable>

<xsl:variable name="base_player">http://www.youtube.com/v/</xsl:variable>

    <xsl:template match="/mpeg7:Mpeg7">
        <xsl:call-template name="top"/>
        
        <xsl:apply-templates select="mpeg7:Description/mpeg7:MultimediaContent/mpeg7:Collection/mpeg7:ContentCollection/mpeg7:Content"/>

        <xsl:call-template name="back"/>
        
   
        <xsl:call-template name="down"/>
        
    </xsl:template>
    
    
    <xsl:template match="mpeg7:Content">
        <!--Identificador del contenido -->
        <xsl:variable name="id_content"><xsl:value-of select="@id"/></xsl:variable>
        <!--Tipo de contenido multimedia -->
        <xsl:variable name="type" select="@xsi:type"/>
        <xsl:variable name="video">Mpeg7:AudioVisualType</xsl:variable>
        <xsl:variable name="imagen">Mpeg7:ImageType</xsl:variable>
        <!-- Icono del repositorio -->
        <xsl:variable name="iconRep" select="mpeg7:AudioVisual/mpeg7:CreationInformation/mpeg7:Creation/mpeg7:Creator/mpeg7:Instrument/mpeg7:Tool/voc:Definition"/>
        
        <!--Tipos de instancias permitidas -->
        <xsl:variable name="videoflv">application/x-shockwave-flash</xsl:variable>
        <xsl:variable name="image-small">image/small</xsl:variable>
        <xsl:variable name="image-medium">image/medium</xsl:variable>
        <xsl:variable name="image-big-">image/big</xsl:variable>
        <xsl:variable name="image-extrabig">image/extrabig</xsl:variable>
        <xsl:variable name="image-original">image/original</xsl:variable>

        
        <!--Se comprueba que el contenido solicitado esta disponible en el mpeg7 -->
        <xsl:if test="$id_content=$id">
            
            <!--Titulo del contenido -->                      
            <xsl:variable name="title">
                <xsl:call-template name="cleanTitle">
                    <xsl:with-param name="string" select="mpeg7:AudioVisual/mpeg7:CreationInformation/mpeg7:Creation/mpeg7:Title"/>
                </xsl:call-template>
            </xsl:variable>
            
            <!--Resumen (abstract del contenido)-->
            <xsl:variable name="resume" select="mpeg7:AudioVisual/mpeg7:CreationInformation/mpeg7:Creation/mpeg7:Abstract/mpeg7:FreeTextAnnotation"/>
            <!--Palabras clave -->
            <xsl:variable name="keywords" select="mpeg7:AudioVisual/mpeg7:CreationInformation/mpeg7:Creation/mpeg7:Abstract/mpeg7:KeywordAnnotation/mpeg7:Keyword"/>
            <!--Autor del contenido-->
            <xsl:variable name="author" select="mpeg7:AudioVisual/mpeg7:CreationInformation/mpeg7:Creation/mpeg7:Creator/mpeg7:Agent/voc:Name"/>
            <!-- Icono del repositorio -->
            <xsl:variable name="iconRep" select="mpeg7:AudioVisual/mpeg7:CreationInformation/mpeg7:Creation/mpeg7:Creator/mpeg7:Instrument/mpeg7:Tool/voc:Definition"/>
            
            <!-- Fecha de creaccion del contenido -->
            <xsl:variable name="date" select="mpeg7:AudioVisual/mpeg7:CreationInformation/mpeg7:Creation/mpeg7:CreationCoordinates/mpeg7:Date/mpeg7:TimePoint"/>
            <!--Categoria del contenido-->
            <xsl:variable name="category"><xsl:call-template name="exists"><xsl:with-param name="string" select="mpeg7:AudioVisual/mpeg7:CreationInformation/mpeg7:Classification/mpeg7:Genre/voc:Name"/></xsl:call-template></xsl:variable>
            <!--Valoracion del contenido-->
            <xsl:variable name="rating"><xsl:call-template name="exists"><xsl:with-param name="string" select="mpeg7:AudioVisual/mpeg7:CreationInformation/mpeg7:Classification/mpeg7:MediaReview/mpeg7:Rating/mpeg7:RatingValue"/></xsl:call-template></xsl:variable>
                        
            
            
            
            
            <div class="post">
            <h1><xsl:value-of select="mpeg7:AudioVisual/mpeg7:CreationInformation/mpeg7:Creation/mpeg7:Title"/></h1>
            
            <table>
                  <tr xmlns="http://www.w3.org/1999/xhtml" valign="top">
                     <td class="align-center">
                       
        
            <!--Se comprueba el tipo del contenido para mostrar su contenido -->
            <xsl:choose>
                <xsl:when test="$type=$video">    
                    <!--Si es un video flv hay que colocar el reproductor flash embebido -->
                    <xsl:variable name="uri_player"><xsl:value-of select="mpeg7:AudioVisual/mpeg7:MediaInformation/mpeg7:MediaProfile[mpeg7:MediaInstance/mpeg7:LocationDescription='application/x-shockwave-flash']/mpeg7:MediaInstance/mpeg7:InstanceIdentifier"/>&amp;hl=es&amp;fs=1</xsl:variable>
                    <object width="425" height="344">
                        <param name="movie"><xsl:attribute name="value"><xsl:value-of select="$uri_player"/></xsl:attribute></param>
                        <param name="allowFullScreen" value="true"></param>
                        <embed type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"><xsl:attribute name="src"><xsl:value-of select="$uri_player"/></xsl:attribute></embed>
                        
                    </object>
                </xsl:when>
                
                <!--Si es una imagen.-->
                <xsl:when test="$type=$imagen">
                    <!-- Mostramos la imagen mediana-->
                    <xsl:variable name="url_img"><xsl:value-of select="mpeg7:AudioVisual/mpeg7:MediaInformation/mpeg7:MediaProfile[mpeg7:MediaInstance/mpeg7:LocationDescription='img/medium']/mpeg7:MediaInstance/mpeg7:InstanceIdentifier"/></xsl:variable>
                    <a><xsl:attribute name="href"><xsl:value-of select="mpeg7:AudioVisual/mpeg7:MediaInformation/mpeg7:MediaProfile[mpeg7:MediaInstance/mpeg7:LocationDescription='img/big']/mpeg7:MediaInstance/mpeg7:InstanceIdentifier"/></xsl:attribute>
                        <img><xsl:attribute name="src"><xsl:value-of select="$url_img"/></xsl:attribute></img> 
                    </a>
                    <div class="botones">
                        <!--Mediana-->
                        <xsl:variable name="url_img_m"><xsl:value-of select="mpeg7:AudioVisual/mpeg7:MediaInformation/mpeg7:MediaProfile[mpeg7:MediaInstance/mpeg7:LocationDescription='img/big']/mpeg7:MediaInstance/mpeg7:InstanceIdentifier"/></xsl:variable>
                        <a class="boton"><xsl:attribute name="href"><xsl:value-of select="$url_img_m"/></xsl:attribute>Mediana </a>
                        <!--Grande-->
                        <xsl:variable name="url_img_g"><xsl:value-of select="mpeg7:AudioVisual/mpeg7:MediaInformation/mpeg7:MediaProfile[mpeg7:MediaInstance/mpeg7:LocationDescription='img/extrabig']/mpeg7:MediaInstance/mpeg7:InstanceIdentifier"/></xsl:variable>
                        <a class="boton"><xsl:attribute name="href"><xsl:value-of select="$url_img_g"/></xsl:attribute>Grande </a>
                        <!--Original-->
                        <xsl:variable name="url_img_o"><xsl:value-of select="mpeg7:AudioVisual/mpeg7:MediaInformation/mpeg7:MediaProfile[mpeg7:MediaInstance/mpeg7:LocationDescription='img/original']/mpeg7:MediaInstance/mpeg7:InstanceIdentifier"/></xsl:variable>
                        <a class="boton"><xsl:attribute name="href"><xsl:value-of select="$url_img_o"/></xsl:attribute>Original </a>
                    </div>
                    
                
                </xsl:when>
                
                <xsl:otherwise>
                    El contenido no se puede visualizar
                </xsl:otherwise>
            </xsl:choose>

                    </td>
                    <td class="derecha">
                        <div class="line">
                           <!--Iconos del tipo y repositorio fuente -->
                           <img><xsl:attribute name="src"><xsl:value-of select="$base_img"/><xsl:value-of select="$iconRep"/></xsl:attribute></img> 
                        </div>
                        <div class="line"><h5>Autor:</h5><xsl:value-of select="$author"/></div>
                        <br/>
                        <div class="line">
                            <div id="resume"><h5>Resumen:</h5><xsl:value-of select="mpeg7:AudioVisual/mpeg7:CreationInformation/mpeg7:Creation/mpeg7:Abstract/mpeg7:FreeTextAnnotation"/></div>
                            <div id="keywords"><h5>keywords:</h5><xsl:value-of select="$keywords"/></div>
                            <div id="genero"><h5>Genero:</h5><xsl:value-of select="$category"/></div>
                            <div id="valoracion"><h5>Valoracion:</h5><xsl:value-of select="$rating"/></div>
                        </div>
                        
                        
                        <!--Enlaces a los otros tamaños (instancias de la fotografia)-->
                        <xsl:if test="$type=$imagen">
                            <br/>
                            <div class="line">
                            <h5>Otros tamaños disponibles de imagen</h5>
                            <!--Mediana-->
                            <xsl:variable name="url_img_m"><xsl:value-of select="mpeg7:AudioVisual/mpeg7:MediaInformation/mpeg7:MediaProfile[mpeg7:MediaInstance/mpeg7:LocationDescription='img/big']/mpeg7:MediaInstance/mpeg7:InstanceIdentifier"/></xsl:variable>
                            <a><xsl:attribute name="href"><xsl:value-of select="$url_img_m"/></xsl:attribute>Mediana </a>
                            <!--Grande-->
                            <xsl:variable name="url_img_g"><xsl:value-of select="mpeg7:AudioVisual/mpeg7:MediaInformation/mpeg7:MediaProfile[mpeg7:MediaInstance/mpeg7:LocationDescription='img/extrabig']/mpeg7:MediaInstance/mpeg7:InstanceIdentifier"/></xsl:variable>
                            <a><xsl:attribute name="href"><xsl:value-of select="$url_img_g"/></xsl:attribute>Grande </a>
                            </div>
                        </xsl:if>
                        
                     </td>
                  </tr>
            </table>
            
            
            
            </div>
            
        </xsl:if>
        


			
    
    </xsl:template>
    
        <!--///////////////////////////
            Obtiene los iconos de tipo de contenido y repositorio
        ///////////////////////////////////////////////////-->
        <xsl:template name="getIcons">
            <xsl:param name="tipo"/>
            <xsl:choose>
                <xsl:when test="$tipo='Mpeg7:ImageType'">
                    <xsl:variable name="icon_type"><xsl:value-of select="$base_img"/>imagen.gif</xsl:variable>
                    <xsl:variable name="type">imagen</xsl:variable>
                    <img class="iconL"><xsl:attribute name="src"><xsl:value-of select="$icon_type"/></xsl:attribute></img>   
                </xsl:when>
                <xsl:when test="$tipo='Mpeg7:AudioVisualType'">
                   <xsl:variable name="icon_type"><xsl:value-of select="$base_img"/>video.gif</xsl:variable>
                   <xsl:variable name="type">video</xsl:variable>
                   <img class="iconL"><xsl:attribute name="src"><xsl:value-of select="$icon_type"/></xsl:attribute></img>   
                </xsl:when>
                <xsl:otherwise>
                    <xsl:variable name="icon_type"><xsl:value-of select="$base_img"/>video.gif</xsl:variable>
                    <img class="iconL"><xsl:attribute name="src"><xsl:value-of select="$icon_type"/></xsl:attribute></img>   
                </xsl:otherwise>
            </xsl:choose>
        </xsl:template>
    
    
    <xsl:template name="back">
        <a id="volver" class="boton"><xsl:attribute name="href"><xsl:value-of select="$base_url"/><xsl:value-of select="$keys_search"/>&amp;start=<xsl:value-of select="$start"/><xsl:call-template name="_order"/></xsl:attribute> Volver</a>
    </xsl:template>
    
    
    <!--Se obtiene la url para la paginacion si hay filtro de ordenacion-->
    <xsl:template name="_order">
            <!--Posible inclusion de filtro de ordenacion-->
            <xsl:choose>
                <xsl:when test="$order!=''">&amp;order=rating</xsl:when>
                <xsl:otherwise></xsl:otherwise>
            </xsl:choose>
           
    </xsl:template>
    
</xsl:stylesheet>
